﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Business : IAccessible<T_Business, Business>, ILogicEntity<T_Business, Business>
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string ContactInfo { get; set; }
        public DateTime CreateDate { get; set; }
        public string Creator { get; set; }
        public string Logo { get; set; }

        /// <summary>
        /// 主营
        /// </summary>
        public string MainSell { get; set; }

        /// <summary>
        /// 送餐时间
        /// </summary>
        public string DeliveryTime { get; set; }
        public string DeliveryTimeEnd { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 特色菜
        /// </summary>
        public string SpecialFood { get; set; }
   
        /// <summary>
        /// 等级（显示星星）
        /// </summary>
        public int Levels { get; set; }

        /// <summary>
        /// 联系人
        /// </summary>
        public string ContactPeople { get; set; }

        protected override void Covariant(T_Business model)
        {
            if (model != null)
            {
                this.ContactInfo = model.ContactInfo;
                this.CreateDate = model.CreateDate;
                this.Creator = model.Creator;
                this.Id = model.Id;
                this.Logo = model.Logo;
                this.Name = model.Name;
                this.DeliveryTime = model.DeliveryTime;
                this.Levels = model.Levels;
                this.MainSell = model.MainSell;
                this.SpecialFood = model.SpecialFood;
                this.Address = model.Address;
                this.DeliveryTimeEnd = model.DeliveryTimeEnd;
                this.ContactPeople = model.ContactPeople;
            }
        }

        protected override T_Business Inverter(Business model)
        {
            if (model != null)
            {
                return new T_Business()
                {
                    ContactInfo = model.ContactInfo,
                    CreateDate = model.CreateDate,
                    Creator = model.Creator,
                    Id = model.Id,
                    Logo = model.Logo,
                    Name = model.Name,
                    DeliveryTime = model.DeliveryTime,
                    Levels = model.Levels,
                    MainSell = model.MainSell,
                    SpecialFood = model.SpecialFood,
                    Address = model.Address,
                    DeliveryTimeEnd = model.DeliveryTimeEnd,
                    ContactPeople = model.ContactPeople
                };
            }
            return null;
        }

        public Business Set(T_Business dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
